package com.ecube.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 日期工具
 *
 * @author zhuweijun
 * @version 1.0.0
 * @since 2025/7/29 11:44
 */
public class DateUtils {

    public final static String DEFAULT_DATE_TIME = "yyyy-MM-dd HH:mm:ss";

    private final static String DEFAULT_DATE_TIME_MS = "yyyyMMddHHmmssSSS";

    /**
     * 当前日期
     * @return {@link String}
     */
    public static String getNowDate() {
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME));
    }

    /**
     * 当前日期时间，带有毫秒
     *
     * @return {@link String}
     */
    public static String getNowDateMs() {
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_MS));
    }

    /**
     * LocalDateTime 转换字符串
     *
     * @param localDateTime localDateTime
     * @return {@link String}
     */
    public static String localDateTimeToStr(LocalDateTime localDateTime) {
        return localDateTime.format(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME));
    }

}
